Page({
  data:{
    list:[],
    arr:[],
    checked:[],
    unchecked:[]
  },
  num(){
    var list = this.data.list
    var res = list.filter(item=>item.state)
    var str = list.filter(item=>!item.state)
    this.setData({
      checked:res,
      unchecked:str
    })
  },
  todo(event){
    if(this.data.arr.indexOf(event.detail.value) ==-1&&event.detail.value!=""){
      this.data.arr.push(event.detail.value)
      this.setData({
        list:[{value:event.detail.value,state:false},
               ...this.data.list]
      })
    }
    this.num()
  },
  onChange(event){
    var index = event.currentTarget.dataset.index
    var list = this.data.list
    list[index].state = !list[index].state
    this.setData({
      list
    })
    this.num()
  },
  onDelete(event){
    var index = event.currentTarget.dataset.index
    this.data.list.splice(index,1)
    this.data.arr.splice(index,1)
    this.setData({
      list:this.data.list,
      arr:this.data.arr
    })
    this.num()
  }
})
